package com.train.order.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.train.common.resp.PageResp;
import com.train.daily.resp.seat.DailyTrainSeatQueryListResp;
import com.train.daily.resp.ticket.DailyTrainTicketQueryOneResp;
import com.train.order.dto.confirm.ConfirmOrderEventDTO;
import com.train.order.dto.confirm.ConfirmOrderPageDTO;
import com.train.order.dto.confirm.ConfirmOrderPageHandleOrderDTO;
import com.train.order.dto.confirm.ConfirmOrderTicketDTO;
import com.train.order.po.ConfirmOrderPO;
import com.train.order.resp.ConfirmOrderPageResp;

import java.time.LocalDate;
import java.util.List;
import java.util.Set;

/**
 * @author baitiaojun
 * @description 针对表【confirmOrder(确认订单)】的数据库操作Service
 * @createDate 2025-03-11 21:07:57
 */
public interface ConfirmOrderService extends IService<ConfirmOrderPO> {

    PageResp<ConfirmOrderPageResp> pageList(ConfirmOrderPageDTO confirmOrderPageDTO);

    /**
     * 确认订单前验证码校验、防刷、余票检查、加锁操作
     * @param dto
     */
    String confirmBeforeProcess(ConfirmOrderTicketDTO dto);

    /**
     * 确认订单主流程
     * @param dto
     */
    void confirmProcess(ConfirmOrderEventDTO dto);

    /**
     * 确认订单后数据库操作
     * @param dto
     * @param choiceSeatList
     * @param startIndex
     * @param endIndex
     */
    void confirmAfterProcess(ConfirmOrderPageHandleOrderDTO dto, List<DailyTrainSeatQueryListResp> choiceSeatList,
                             Integer startIndex, Integer endIndex);

    void validateCaptcha(ConfirmOrderTicketDTO dto);

    void preventTicketScalping(LocalDate date, String trainCode, Long memberId);

    void validateTrainTicketToken(LocalDate date, String trainCode, Set<Integer> seatTypeSet);

    DailyTrainTicketQueryOneResp queryDailyTrainTicket(ConfirmOrderPageHandleOrderDTO dto, LocalDate date, String trainCode);

    void preReduce(ConfirmOrderPageHandleOrderDTO dto, DailyTrainTicketQueryOneResp dailyTrainTicket);

    List<DailyTrainSeatQueryListResp> chooseSeat(LocalDate date, String trainCode,
                                                 List<ConfirmOrderTicketDTO.PassengerTicket> ticketList,
                                                 DailyTrainTicketQueryOneResp dailyTrainTicket);

    void updateConfirmOrderStatus(Long id, String status);

    String queryWaitingStatus(Long orderId);

    void cancelOrderConfirm(Long orderId);
}
